package com.uzai.console.web.wechatwork;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.wechatwork.openapiinfo.WxworkOpenapiInfoDto;
import com.uzai.console.dto.wechatwork.openapiinfo.WxworkOpenapiInfoIdDto;
import com.uzai.console.dto.wechatwork.openapiinfo.WxworkOpenapiInfoQuery;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.device.DeviceService;
import com.uzai.console.service.wechatwork.WxworkOpenapiInfoService;
import com.uzai.console.vo.wechatwork.openapiinfo.WxworkOpenapiInfoVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 企业微信授权渠道
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "企业微信授权渠道",tags = "企业微信|企业微信授权渠道")
@ApiSort(5)
@RestController
public class WxworkOpenapiInfoController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(WxworkOpenapiInfoController.class);

    @Autowired
    private WxworkOpenapiInfoService wxworkOpenapiInfoService;
    @Autowired
    private DeviceService deviceService;

    @ApiOperation(value = "分页查询企业微信授权渠道列表", notes = "分页查询企业微信授权渠道列表", response = WxworkOpenapiInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/wxworkOpenapiInfo/findByPage")
    public Object findWxworkOpenapiInfoPage(@RequestBody WxworkOpenapiInfoQuery wxworkOpenapiInfoQuery){
        return wxworkOpenapiInfoService.findWxworkOpenapiInfoPage(wxworkOpenapiInfoQuery);
    }

    @ApiOperation(value = "查询企业微信授权渠道详情", notes = "查询企业微信授权渠道详情", response = WxworkOpenapiInfoVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/wxworkOpenapiInfo/findById")
    public Object findWxworkOpenapiInfo(@RequestBody WxworkOpenapiInfoIdDto wxworkOpenapiInfoIdDto){
        return wxworkOpenapiInfoService.findWxworkOpenapiInfo(wxworkOpenapiInfoIdDto);
    }

    @SystemLogType(model = SystemModelEnum.DeviceWxWorkOpenapiInfo, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加企业微信授权渠道", notes = "添加企业微信授权渠道")
    @ApiOperationSupport(order = 3)
    @PostMapping("/wxworkOpenapiInfo/add")
    public Object addUserTypeGroup(@RequestBody WxworkOpenapiInfoDto wxworkOpenapiInfoDto){
        wxworkOpenapiInfoService.addWxworkOpenapiInfo(wxworkOpenapiInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWxWorkOpenapiInfo, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改企业微信授权渠道", notes = "修改企业微信授权渠道")
    @ApiOperationSupport(order = 4)
    @PostMapping("/wxworkOpenapiInfo/update")
    public Object updateUserTypeGroup(@RequestBody WxworkOpenapiInfoDto wxworkOpenapiInfoDto){
        wxworkOpenapiInfoService.updateWxworkOpenapiInfo(wxworkOpenapiInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWxWorkOpenapiInfo, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除企业微信授权渠道", notes = "删除企业微信授权渠道")
    @ApiOperationSupport(order = 5)
    @PostMapping("/wxworkOpenapiInfo/delete")
    public Object wxworkOpenapiInfoService(@RequestBody WxworkOpenapiInfoIdDto wxworkOpenapiInfoIdDto){
        wxworkOpenapiInfoService.deleteWxworkOpenapiInfo(wxworkOpenapiInfoIdDto);
        return true;
    }

    @ApiOperation(value = "查询所有企业微信授权渠道列表", notes = "查询所有企业微信授权渠道列表", response = WxworkOpenapiInfoVo.class)
    @ApiOperationSupport(order = 6)
    @PostMapping("/wxworkOpenapiInfo/findByList")
    public Object findWxworkOpenapiInfoList(@RequestBody WxworkOpenapiInfoQuery wxworkOpenapiInfoQuery){
        return wxworkOpenapiInfoService.findWxworkOpenapiInfoList(wxworkOpenapiInfoQuery);
    }

}
